/* Copyright 203-2115 AtomWare Technology Pty Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * The flowing information must be keep 
 * BusinessObject.java
 * myapp
 * 2012-9-18下午4:07:53
 * @author 屈甲康
 * QQ285799123
 * mailto:qujiakang@gmail.com
 */

package org.jackysoft.entity;

import java.util.Collection;

import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany;

import org.apache.struts2.json.annotations.JSON;
import org.hibernate.annotations.Type;
import org.jackysoft.util.MySqlSchema;
import org.joda.time.DateTime;

import com.google.common.collect.Lists;

@MappedSuperclass
public abstract class BusinessObject extends AbstractEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2407235926493113403L;
	protected User applicant;
	protected Department department;
	protected String title;
	protected String formId;
	protected DateTime startDate;    
	protected DateTime endDate;
	protected String officeId;
	protected Collection<Attachment> attachments;
    
    
    
    public BusinessObject() {
    	
		super();
		attachments = Lists.newArrayList();
		
	}

	@ManyToOne
    public User getApplicant() {
		return applicant;
	}

	public void setApplicant(User applicant) {
		this.applicant = applicant;
	}

	@ManyToOne
	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getFormId() {
		return formId;
	}

	public void setFormId(String formId) {
		this.formId = formId;
	}

	public String getOfficeId() {
		return officeId;
	}

	public void setOfficeId(String officeId) {
		this.officeId = officeId;
	}

	@OneToMany
	@JoinTable(schema=MySqlSchema.Businessbase)
	@JSON(serialize=false)
	public Collection<Attachment> getAttachments() {
		return attachments;
	}

	public void setAttachments(Collection<Attachment> attachments) {
		this.attachments = attachments;
	}

	@Type(type = "jodatime")
	public DateTime getStartDate() {
		return startDate;
	}



	public void setStartDate(DateTime startDate) {
		this.startDate = startDate;
	}



	@Type(type = "jodatime")
	public DateTime getEndDate() {
		return endDate;
	}



	public void setEndDate(DateTime endDate) {
		this.endDate = endDate;
	}

}
